<?php

(defined('BASEPATH')) OR exit('No direct script access allowed');

class Admin_Controller extends MY_Controller {
    /**
     * Constructor
     */
    public function __construct()
    {
        parent::__construct();
        
        // These pages get past permission checks
        $ignored_pages = array('account/login', 'account/logout', 'account/help');

        // Check if the current page is to be ignored
        $current_page = $this->uri->segment(2, '') . '/' . $this->uri->segment(3, 'index');
        
        // Dont need to log in, this is an open page
        if (in_array($current_page, $ignored_pages))
        {
            return TRUE;
        }
        else if ( ! $this->auth->is_admin())
        {
            redirect('/backend/account/login');
        }
    }
}